package com.srcptit.trainning.toannt.btvn2;
import java.util.Scanner; 

public class Dem_tu 
{ 
    public static int count(String s) //dem so tu trong chuoi
    { 
        int i = 0, count = 1; 
        char[] s1 = s.toCharArray(); 
         
        while(s1[i] == ' ') 
        { 
            i++; 
        } 

        for (int j = i; j < s1.length - 1; j++) 
        { 
            if(s1[j] == ' ' && s1[j + 1] != ' ') 
            { 
                count++; 
            } 
        } 

        return count; 
    } 
//chuong trinh chinh
    public static void main(String[] args) 
    { 
    	Scanner sc=new Scanner(System.in);
        System.out.println("Nhap vao 1 chuoi: " ); 
       String s=sc.nextLine();
      System.out.println("So tu trong chuoi vua nhap la: "+count(s));  
        
    } 
} 